module MC {
	export class Page {
		public selectBody:JQuery=null;
		private url:string;
		private par:any;
		private fun:Function;
		private page:number=0;
		private limit=10;
		public constructor(select:string,url:string,par:any,fun:Function,limit=10) {
			this.selectBody=$(select);
			this.url=url;
			this.par=par;
			this.fun=fun;
			this.limit=limit; 
		}
		private bottom:JQuery=$(`<div class="MoreListDiv"><a class="MoreList">点击显示更多</a></div>`);
		public init(){ 
			this.selectBody.append(this.bottom);
			this.bottom.on('click',()=>{ 
				MC.click(()=>{
					this.Load();
				});
			});
			this.Load();			
		}
		private Load(){
			 
			this.par.page=this.page;
		//	this.bottom.hide();
			if(this.page==0){
				MC.apiD(this.url,this.par,(list:any)=>{
					this.loadCom(list);
				});
			}else{
				MC.apiD(this.url,this.par,(list:any)=>{
					this.loadCom(list);
				});
			} 
		}
		private loadCom(list:any){
			if(list.length>=10){
				this.bottom.show();
			}else{
					this.bottom.hide();
			}
			this.fun(list,this.page);
			this.page++;
		}
	}
}